<?php
 
 // This allows us to have our own settings without having to cripple the svn version
 // the private.database.php file contains exactly what is inside the else block
 // but with actual values! The second include the site to function within the
 // environment we use for developing the DMDirc website, and just points at the
 // live copy of the private.database.php file.
 
 if (file_exists(dirname(__FILE__) . '/private.database.php')) {
  require_once(dirname(__FILE__) . '/private.database.php');
 } else if (file_exists('../../addons/inc/private.database.php')) {
  require_once('../../addons/inc/private.database.php');
 } else {
  define('DB_NAME', 'dbname');    // The name of the database
  define('DB_USER', 'dbuser');     // Your MySQL username
  define('DB_PASSWORD', 'dbpassword'); // ...and password
  define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
 }
 
 $status = false !== @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
 $status = $status & @mysql_select_db(DB_NAME);

 if (!$status) {
  header('HTTP/1.1 500 Internal Server Error');

  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', "\r\n";
  echo '<html>', "\r\n";
  echo ' <title>DMDirc addons directory :: 500 - Internal Server Error</title>', "\r\n";
  echo ' <style type="text/css">', "\r\n";
  echo '  body { background-color: black; color: white; margin: 150px 20%; }', "\r\n";
  echo '  div { text-align: center; font-family: sans-serif; }', "\r\n";
  echo ' </style>', "\r\n";
  echo ' <body>', "\r\n";
  echo '  <div>', "\r\n";
  echo '   <img src="http://www.dmdirc.com/res/logo.png" alt="DMDirc logo">', "\r\n";
  echo '   <h1>500 - Internal Server Error</h1>', "\r\n";
  echo '   <p>Sorry. An internal error occured while processing your request.</p>', "\r\n";
  echo '   <p>Please try again later.</p>', "\r\n";
  echo '  </div>', "\r\n";
  echo ' </body>', "\r\n";
  echo '</html>', "\r\n";
  die();
 }
 
 /**
  * Escapes the specified string so it can be used in a MySQL query.
  *
  * @param String $sql The string to be escaped
  * @see mysql_real_escape_string
  * @return String An escaped version of the string
  */
 function m($sql) {
  return mysql_real_escape_string($sql);
 }
 
?>
